package com.itany.corejava.day13;

import java.io.File;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.net.URL;

public class TestPath {

    public static void main(String[] args) throws URISyntaxException {
        //相对于CLASSPATH找文件
        InputStream in=TestPath.class
                               .getClassLoader()
                               .getResourceAsStream("a.txt");

        URL url=TestPath.class
                        .getClassLoader()
                        .getResource("a.txt");

        System.out.println(url);

        File file=new File(url.toURI());

        System.out.println(file.exists());

        System.out.println(file.length());



        //相对于当前类的字节码找文件
        InputStream in2=TestPath.class
                                .getResourceAsStream("a.txt");

        URL url2=TestPath.class
                         .getResource("a.txt");

        System.out.println(url2);
    }


}
